package com.xiangxiao.rpan.authority.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xiangxiao.rpan.authority.tree.TreeNode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Projectname: walarm-authority
 * @Author: xiangxiao
 * @Email: 573768011@qq.com
 * @Data:2022/11/10 1:27
 */
@Data
public class AuthModuleInfo implements Serializable, Cloneable, TreeNode {
    private static final long serialVersionUID = 3866827044760227032L;

    private Long id;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    private Long menuId;

    private String menuName;

    private String url;

    private Boolean hasChild;

//    private List<AuthorityDetail> authorityDetails;

    private Long parentId;

    private String resourceCode;


    private List<TreeNode> childList = new ArrayList<>();

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public String getName() {
        return null;
    }

    @Override
    public TreeNode copyWithoutTreeInfo() {
        try {
            AuthModuleInfo treeNode = (AuthModuleInfo) super.clone();
            treeNode.childList = new ArrayList<>();
            return treeNode;
        } catch (CloneNotSupportedException e) {
            return null;
        }

    }

    @Override
    public List<TreeNode> getChildList() {
        return childList;
    };

    @Override
    public boolean getHasChild() {
        return hasChild;
    }

    @Override
    public void setHasChild(boolean hasChild) {
        this.hasChild = hasChild;
    }
}
